<template>
  <div class="page-common">
    <div class="news-title">
      <h4>{{newsInfo.title}}</h4>
      <p>{{newsInfo.add_time|datefmt('YYYY-MM-DD HH:mm:ss')}} {{newsInfo.click}} 次浏览</p>
    </div>
    <div id="new_content">
     {{newsInfo.content}}
    </div>
    <common :id = "id"></common>
  </div>
</template>
<script>
  import common from '../components/Common.vue'
  import Common from '../kits/common.js'
  export default {
    data() {
      return {
        newsInfo:{}, //新闻每一条列表
        id:0 , //穿入的id值
        url:'http://192.168.11.26:3000/mock/47/news/newsinfo:id'
      }
    },
    components: {
      common
    },
    methods:{
      getnewsInfoDate(){
//          let url = '/news/newsinfo/' + this.id;
//          console.log(url);
//           this.axios.get("../static/newContent.json/",{}).then(res => this.newsInfoDate = res.data.message);
        this.axios.get(this.url,{}).then( res => this.newsInfo = res.data.message[0])
       }
    },
    created(){
//      1.0 获取url传入的id参数值赋值给data中的id属性,这里的id与路由规则中的：id名字一样
      this.id = this.$route.params.id;

//            2.0 请求服务器获取到这个id对应的详情数据对象
      this.getnewsInfoDate();
    }
  }
</script>
<style scoped>
</style>
